/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package uit_vendor_management;

import java.awt.Color;

/**
 *
 * @author user
 */
public class ThayDoiQuyDinhForm extends javax.swing.JFrame {

    /**
     * Creates new form ThayDoiQuyDinhForm
     */
    Database myDatabase = Database.instance;
    boolean isSoLuongCacLoaiDaiLy = false;
    boolean isSoLuongToiDaDaiLy = false;
    boolean isTienNoToiDa = false;
    
    public ThayDoiQuyDinhForm() {
        initComponents();
        
        // init language
        this.initLanguage();
        this.initComboBox();
        
        // set visible
        lblError.setVisible(false);
    }

    private void initLanguage()
    {
        lblThayDoiQuyDInh.setText(Language._("THAYDOIQUYDINH_FORM_THAYDOIQUYDINH_LBL"));
        lblQuyDinh1.setText(Language._("THAYDOIQUYDINH_FORM_QUYDINH1_LBL"));
        lblQuan.setText(Language._("THAYDOIQUYDINH_FORM_QUAN_LBL"));
        lblSoLuongCacLoaiDaiLyHienTai.setText(Language._("THAYDOIQUYDINH_FORM_SOLUONGCACLOAIDAILYHIENTAI_LBL"));
        lblSoLuongToiDaCacLoaiDaiLy.setText(Language._("THAYDOIQUYDINH_FORM_SOLUONGTOIDACACLOAIDAILY_LBL"));
        
        lblQuyDinh2.setText(Language._("THAYDOIQUYDINH_FORM_QUYDINH2_LBL"));
        lblTienNoToiDa.setText(Language._("THAYDOIQUYDINH_FORM_TIENNOTOIDA_LBL"));
        
        btnLuu.setText(Language._("THAYDOIQUYDINH_FORM_LUU_LBL"));
        btnThoat.setText(Language._("THAYDOIQUYDINH_FORM_THOAT_LBL"));
    }
    
    private void initComboBox()
    {
        QueryResult result =  myDatabase.Query("SELECT * FROM QUAN");
        if (result.ReturnCode == 200)
        {
            DataTable table = result.Table;
            for (int i = 0 ; i < table.getRowCount() ; i++)
            {
                String row = table.getValueAt(i, 1).toString();
                cbxQuan.addItem(row);
            }
        }
        
        result = myDatabase.Query("SELECT * FROM LOAIDAILY");
        if (result.ReturnCode == 200)
        {
           DataTable table = result.Table;
            for (int i = 0 ; i < table.getRowCount() ; i++)
            {
                String row = table.getValueAt(i, 1).toString();
                cbxLoaiDaiLy.addItem(row);
            }
        }
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblThayDoiQuyDInh = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        lblQuan = new javax.swing.JLabel();
        lblSoLuongCacLoaiDaiLyHienTai = new javax.swing.JLabel();
        lblSoLuongToiDaCacLoaiDaiLy = new javax.swing.JLabel();
        cbxQuan = new javax.swing.JComboBox();
        txbSoLuongDaiLyHienTai = new javax.swing.JTextField();
        txbSoLuongDaiLyToiDa = new javax.swing.JTextField();
        lblQuyDinh1 = new javax.swing.JLabel();
        lblQuyDinh2 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        lblLoaiDaiLy = new javax.swing.JLabel();
        lblTienNoToiDa = new javax.swing.JLabel();
        cbxLoaiDaiLy = new javax.swing.JComboBox();
        txbTienNoToiDa = new javax.swing.JTextField();
        btnLuu = new javax.swing.JButton();
        btnThoat = new javax.swing.JButton();
        lblError = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Thay Đổi Quy Định");

        lblThayDoiQuyDInh.setFont(new java.awt.Font("Calibri", 0, 36)); // NOI18N
        lblThayDoiQuyDInh.setText("THAY ĐỔI QUY ĐỊNH");

        jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        lblQuan.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        lblQuan.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblQuan.setText("Quận");

        lblSoLuongCacLoaiDaiLyHienTai.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        lblSoLuongCacLoaiDaiLyHienTai.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblSoLuongCacLoaiDaiLyHienTai.setText("Số lượng các loại đại lý ");

        lblSoLuongToiDaCacLoaiDaiLy.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        lblSoLuongToiDaCacLoaiDaiLy.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblSoLuongToiDaCacLoaiDaiLy.setText("Số lượng tối đa đại lý");

        cbxQuan.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        cbxQuan.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbxQuan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxQuanActionPerformed(evt);
            }
        });

        txbSoLuongDaiLyHienTai.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        txbSoLuongDaiLyHienTai.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txbSoLuongDaiLyHienTaiFocusLost(evt);
            }
        });

        txbSoLuongDaiLyToiDa.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        txbSoLuongDaiLyToiDa.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txbSoLuongDaiLyToiDaFocusLost(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(lblSoLuongCacLoaiDaiLyHienTai, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                    .addComponent(lblSoLuongToiDaCacLoaiDaiLy, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblQuan, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbxQuan, 0, 200, Short.MAX_VALUE)
                    .addComponent(txbSoLuongDaiLyHienTai)
                    .addComponent(txbSoLuongDaiLyToiDa))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblQuan)
                    .addComponent(cbxQuan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblSoLuongCacLoaiDaiLyHienTai)
                    .addComponent(txbSoLuongDaiLyHienTai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblSoLuongToiDaCacLoaiDaiLy)
                    .addComponent(txbSoLuongDaiLyToiDa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        lblQuyDinh1.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        lblQuyDinh1.setText("Quy Định 1");

        lblQuyDinh2.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        lblQuyDinh2.setText("Quy Định 2");

        jPanel2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        lblLoaiDaiLy.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        lblLoaiDaiLy.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblLoaiDaiLy.setText("Loại đại lý");

        lblTienNoToiDa.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        lblTienNoToiDa.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        lblTienNoToiDa.setText("Tiền nợ tối đa");

        cbxLoaiDaiLy.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        cbxLoaiDaiLy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cbxLoaiDaiLy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbxLoaiDaiLyActionPerformed(evt);
            }
        });

        txbTienNoToiDa.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        txbTienNoToiDa.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txbTienNoToiDaFocusLost(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(lblTienNoToiDa, javax.swing.GroupLayout.DEFAULT_SIZE, 204, Short.MAX_VALUE)
                    .addComponent(lblLoaiDaiLy, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txbTienNoToiDa)
                    .addComponent(cbxLoaiDaiLy, 0, 200, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblLoaiDaiLy)
                    .addComponent(cbxLoaiDaiLy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txbTienNoToiDa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblTienNoToiDa))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        btnLuu.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        btnLuu.setText("Lưu");
        btnLuu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLuuActionPerformed(evt);
            }
        });

        btnThoat.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        btnThoat.setText("Thoat");
        btnThoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnThoatActionPerformed(evt);
            }
        });

        lblError.setForeground(new java.awt.Color(255, 0, 51));
        lblError.setText("jLabel1");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(67, 67, 67)
                                .addComponent(lblThayDoiQuyDInh))
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblQuyDinh1)
                            .addComponent(lblQuyDinh2)
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(120, 120, 120)
                        .addComponent(btnLuu, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(44, 44, 44)
                        .addComponent(btnThoat, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(195, 195, 195)
                        .addComponent(lblError)))
                .addContainerGap(20, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblThayDoiQuyDInh, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(lblQuyDinh1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(lblQuyDinh2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblError)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnLuu)
                    .addComponent(btnThoat))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnThoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnThoatActionPerformed
        // TODO add your handling code here:
        this.dispose();
    }//GEN-LAST:event_btnThoatActionPerformed

    private void btnLuuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLuuActionPerformed
        // TODO add your handling code here:
        boolean isEverythingOK = isSoLuongCacLoaiDaiLy && isSoLuongToiDaDaiLy && isTienNoToiDa;
        if (isEverythingOK)
        {
            String loaiDaiLy = cbxLoaiDaiLy.getSelectedItem().toString();
            QueryResult result = myDatabase.Query("SELECT MaLoaiDaiLy FROM DAILY WHERE TenLoaiDaiLy = '" + loaiDaiLy + "'");
            if (result.ReturnCode == 200)
            {
                String maLoaiDaiLy = result.Table.getValueAt(0, 0).toString();
                myDatabase.Query("UPDATE QUYDINHTIENNO SET TienNoToiDa = '" + txbTienNoToiDa + "' WHERE MaLoaiDaiLy = '"+ maLoaiDaiLy + "'");
                
               
            }
            
            String tenQuan = cbxQuan.getSelectedItem().toString();
            result = myDatabase.Query("SELECT MaQuan FROM QUAN WHERE TenQuan = '" + tenQuan + "'");
            if (result.ReturnCode == 200)
            {
                String maQuan = result.Table.getValueAt(0, 0).toString();
                myDatabase.Query("UPDATE QUAN SET SoDaiLyToiDa = '" + txbSoLuongDaiLyToiDa.getText() + "' WHERE MaQuan = '" + maQuan + "'");
                
               myDatabase.Query("UPDATE QUYCHETOCHUC SET SoLoaiDaiLy = '" + txbSoLuongDaiLyHienTai.getText() + "' WHERE MaQuan = '" + maQuan + "'");
            }
        }
    }//GEN-LAST:event_btnLuuActionPerformed

    private void cbxQuanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxQuanActionPerformed
        // TODO add your handling code here:
        String tenQuan = cbxQuan.getSelectedItem().toString();
        QueryResult result = myDatabase.Query("SELECT * FROM QUAN WHERE TenQuan = '" + tenQuan + "'");
        if (result.ReturnCode == 200)
        {
            txbSoLuongDaiLyToiDa.setText(result.Table.getValueAt(0, 2).toString());
        }
       String maQuan = myDatabase.Query("SELECT MaQuan FROM QUAN WHERE TenQuan = '" + tenQuan + "'").Table.getValueAt(0, 0).toString();
        result = myDatabase.Query("SELECT SoLoaiDaiLy FROM QUYCHETOCHUC WHERE MaQuan = '" + maQuan + "'");
        if (result.ReturnCode == 200)
        {
            txbSoLuongDaiLyToiDa.setText(result.Table.getValueAt(0, 0).toString());
        }
    }//GEN-LAST:event_cbxQuanActionPerformed

    private void cbxLoaiDaiLyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbxLoaiDaiLyActionPerformed
        // TODO add your handling code here:
        String loaiDaiLy = cbxLoaiDaiLy.getSelectedItem().toString();
        QueryResult result = myDatabase.Query("SELECT TienNoToDa FROM LOAIDAILY, QUYDINHTIENNO WHERE TenLoaiDaiLy = '" + loaiDaiLy + "' AND "
                + "LOAIDAILY.MaLoaiDaiLy = QUYDINHTIENNO.MaLoaiDaiLy");
        if (result.ReturnCode == 200)
        {
            txbTienNoToiDa.setText(result.Table.getValueAt(0, 0).toString());
        }
    }//GEN-LAST:event_cbxLoaiDaiLyActionPerformed

    private void txbTienNoToiDaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txbTienNoToiDaFocusLost
        // TODO add your handling code here:
        boolean isHasError = false;
        if ("".equals(txbTienNoToiDa.getText()))
        {
            isHasError = true;
        }
        
        if (isHasError)
        {
            isTienNoToiDa = false;
            
            txbTienNoToiDa.setBackground(Color.red);
            lblError.setVisible(true);
            lblError.setText(Language._("ERROR_TIENNOTOIDA_NULL"));
        }
        else
        {
            isTienNoToiDa = true;
            txbTienNoToiDa.setBackground(Color.white);
            lblError.setVisible(false);
        }
        
    }//GEN-LAST:event_txbTienNoToiDaFocusLost

    private void txbSoLuongDaiLyToiDaFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txbSoLuongDaiLyToiDaFocusLost
        // TODO add your handling code here:
        boolean isHasError = false;
        if ("".equals(txbSoLuongDaiLyToiDa.getText()))
        {
            isHasError = true;
        }
        
        if (isHasError)
        {
            isSoLuongToiDaDaiLy = false;
            
            txbSoLuongDaiLyToiDa.setBackground(Color.red);
            lblError.setVisible(true);
            lblError.setText(Language._("ERROR_SOLUONGDAILYTOIDA_NULL"));
        }
        else
        {
            isSoLuongToiDaDaiLy = true;
            txbSoLuongDaiLyToiDa.setBackground(Color.white);
            lblError.setVisible(false);
        }
    }//GEN-LAST:event_txbSoLuongDaiLyToiDaFocusLost

    private void txbSoLuongDaiLyHienTaiFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txbSoLuongDaiLyHienTaiFocusLost
        // TODO add your handling code here:
        boolean isHasError = false;
        if ("".equals(txbSoLuongDaiLyHienTai.getText()))
        {
            isHasError = true;
        }
        
        if (isHasError)
        {
            isSoLuongCacLoaiDaiLy = false;
            
            txbSoLuongDaiLyHienTai.setBackground(Color.red);
            lblError.setVisible(true);
            lblError.setText(Language._("ERROR_SOLUONGCACLOAIDAIY_NULL"));
        }
        else
        {
            isSoLuongCacLoaiDaiLy = true;
            txbSoLuongDaiLyHienTai.setBackground(Color.white);
            lblError.setVisible(false);
        }
    }//GEN-LAST:event_txbSoLuongDaiLyHienTaiFocusLost


    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ThayDoiQuyDinhForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ThayDoiQuyDinhForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ThayDoiQuyDinhForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ThayDoiQuyDinhForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ThayDoiQuyDinhForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnLuu;
    private javax.swing.JButton btnThoat;
    private javax.swing.JComboBox cbxLoaiDaiLy;
    private javax.swing.JComboBox cbxQuan;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel lblError;
    private javax.swing.JLabel lblLoaiDaiLy;
    private javax.swing.JLabel lblQuan;
    private javax.swing.JLabel lblQuyDinh1;
    private javax.swing.JLabel lblQuyDinh2;
    private javax.swing.JLabel lblSoLuongCacLoaiDaiLyHienTai;
    private javax.swing.JLabel lblSoLuongToiDaCacLoaiDaiLy;
    private javax.swing.JLabel lblThayDoiQuyDInh;
    private javax.swing.JLabel lblTienNoToiDa;
    private javax.swing.JTextField txbSoLuongDaiLyHienTai;
    private javax.swing.JTextField txbSoLuongDaiLyToiDa;
    private javax.swing.JTextField txbTienNoToiDa;
    // End of variables declaration//GEN-END:variables
}
